package de.ifgi;

import java.util.ArrayList;

public class NodesList extends ArrayList<Node> {
	
	/**
	 * Generated serial version ID
	 */
	private static final long serialVersionUID = -6694554685784182312L;
	private static NodesList nodesList;
	private boolean isUsed;
	
	private NodesList() {
		super();
	}
	
	public static NodesList getNodesList() {
		if (nodesList == null)
			nodesList = new NodesList();
		return nodesList;
	}

	public boolean isUsed() {
		return isUsed;
	}

	public void setUsed(boolean isUsed) {
		this.isUsed = isUsed;
	}

	public void updateNode(Node node) {
		int nodeId = 0;
		String btName = node.getBtName();
		for (Node n : this) {
			if (n.getBtName().equalsIgnoreCase(btName))
				nodeId = this.indexOf(n);
		}
		this.set(nodeId, node);
	}
	
	public boolean hasNode(Node node) {
		boolean hasNode = false;
		String btName = node.getBtName();
		for (Node n : this) {
			if (n.getBtName().equalsIgnoreCase(btName)) {
				hasNode = true;
			}
		}
		return hasNode;
	}

}
